#pragma once

#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <stdio.h>
#include <math.h>
#include <fstream>
#include "opencv2/video/background_segm.hpp"

#include "BackgroundSegmentation.h"
#include "OpticalFlow.h"
#include "PatchFinder.h"
#include "ImageMethods.h"
#include "RGBColour.h"
#include "ResourceLibrary.h"

class OpticalFlow;
class PatchFinder;
class ImageStitcher;
class ResourceLibrary;
using namespace cv;

class BgSegmenter
{
public:

	//float	r, g, b;
	Mat foreground;
	Mat frame;
	Mat image;
	Mat prev_frame;
	BackgroundSubtractorMOG2 mog;
	ResourceLibrary* rl;
	ImageMethods* im;
	OpticalFlow* of;
	ImageStitcher* is;
	PatchFinder* pf;
	vector<IplImage> images;
	vector<IplImage> originals;

	BgSegmenter(void);							//Constructor
	~BgSegmenter(void);

	Mat BgSegmenter::getCurrentFrame();
	Mat BgSegmenter::getPrevFrame();
	IplImage* BgSegmenter::subtractOpticalFlow(IplImage* curr_frame, IplImage* fg);
	void BgSegmenter::removeTemporal(int filter_size);
	void BgSegmenter::removeOpticalFlow(int f);
	int BgSegmenter::segmentBackground(int filter_size, String filename, int save);
	int BgSegmenter::createImages(String filename);
	void BgSegmenter::saveCorrections();
	void BgSegmenter::showImages();
	int BgSegmenter::stitchImages();
	void onMouse( int event, int x, int y, int flags, void* param );

};
